// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from '@/vuex/index' // 引入vuex
import VConsole from 'vconsole' // 引入vconsole依赖，可以在网址后面加上isDebug=true在手机上打印
import '@/assets/css/global.less';
import http from '@/utils/http'

import { LoadingPlugin, ToastPlugin, AlertPlugin, ConfirmPlugin} from 'vux'
Vue.use(LoadingPlugin);
Vue.use(ToastPlugin);
Vue.use(ConfirmPlugin);
Vue.use(AlertPlugin);


router.beforeEach((to, from, next) => { // 具体实现在手机上打印
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
      document.title = to.meta.title
  }
  if(to.query.isDebug || from.query.isDebug){
    if(!window.isDebug){
      window.isDebug = true;
      new VConsole();
    }
  }
  if(from.name == null && to.query.token){
      sessionStorage.setItem("plus_token",to.query.token);
  }
  next()
})

Vue.config.productionTip = false
Vue.prototype.post = http.post

/* eslint-disable no-new */
window._vue = new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
